<template>
  <view-box ref="viewBox" body-padding-bottom="0px">
    <x-img :src="qrcode" class="qrcode" :offset="-100" container="#vux_view_box_body"></x-img>
  </view-box>
</template>
<script>
  import { ViewBox, XImg } from 'vux'
  import { share } from '@/utils/jssdk'
  export default {
    data () {
      return {
        qrcode: null
      }
    },
    components: {
      ViewBox,
      XImg
    },
    mounted () {
      let type = this.$route.query.type ? this.$route.query.type : 1
      let from = this.$route.query.from ? this.$route.query.from : ''
      this.$vux.loading.show()
      this.$http.get('/wechat/qrcode?type=' + type + '&from=' + from).then((response) => {
        this.qrcode = response.data
        share({
          title: '您的好友邀请您关注天南山文化',
          desc: '您的好友邀请您关注天南山文化！',
          link: 'http://m.tnswh.yuethink.cn/?#/sharecard/' + encodeURIComponent(this.qrcode),
          imgUrl: this.qrcode
        }, false)
        this.$vux.loading.hide()
      })
    }
  }
</script>
<style scoped lang="less">
  .qrcode {
    width: 100%;
    height: 100%;
  }
</style>